<template>
   <div>

        <div class="about" >
            <el-table
            :data="list"
            style="width: 90%">       

                <el-table-column label="序号" type="index"  width="100"></el-table-column>
                <el-table-column label="编号" prop="id" width="100"></el-table-column>
                <el-table-column label="名称" prop="name" width="100"></el-table-column>
                <el-table-column label="批次号" prop="number"></el-table-column>
                <el-table-column label="厂家名称" prop="changjia"></el-table-column>
                <el-table-column label="数量" prop="count"></el-table-column>
                <el-table-column label="疫苗类型" prop="type"></el-table-column>
                <el-table-column label="疫苗次数" prop="times"></el-table-column>
                <el-table-column label="相隔时间" prop="date"></el-table-column>
            

                <el-table-column >
                <template  slot-scope="scope">
                  <el-button type="text" @click="open(scope.row)">添加疫苗</el-button>
                </template>
                </el-table-column>
            </el-table>
        </div>


   </div>
</template>

<script>
    export default {
    data(){
        return{
            value: 0,
            list:[],
            vaccineNumber : 0
        }
    },

    created(){
        this.vaccineQuery();
    },
     methods: {
     open(row) {
        this.$prompt('请输入数量', '添加疫苗', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          inputPattern: /[1-9][0-9]*/,
          inputErrorMessage: '输入错误'
        }).then(({ value }) => {
          this.value = Number(value);
          row.count+=this.value;

          this.$api_l._api_list_update(row).then((response)=>{
            
           
          }).catch((error)=>{

          });   
          this.$message({
            type: 'success',
            message: '添加疫苗数：' + this.value
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '取消输入'
          });       
        });
      },
      vaccineQuery(){
          this.$api_l._api_list_vaccine().then((response)=>{
            this.list = response;
            this.list.forEach(element => {
               this.vaccineNumber += element.count;
            });
          }).catch((error)=>{

          });          
      }
    }
}
</script>
